package com.framework.loippi.support;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.framework.loippi.mybatis.ext.annotation.Column;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({ "handler","hibernateLazyInitializer" }) 
@ApiModel(value="登录信息",description="登录信息")
public class APIPrincipal {

	public static final String PREFIX_USER_SESSION = "APP_API_SESSION_";
	
	public static final String PORPERTITY_AUTHENTICATION = "authentication";

	/**
	 * 鉴权码
	 */
	@ApiModelProperty(value = "鉴权码")
	private String authentication;

	/**
	 * 账户id
	 */
	@ApiModelProperty(value = "用户id")
	private Long id;
	
	/**
	 * 账户
	 */
	@ApiModelProperty(value = "账户")
	private String account ;

	/** 昵称 */
	@ApiModelProperty(value = "昵称")
	private String nickName;

	/** 头像 */
	@ApiModelProperty(value = "头像")
	private String avatar;
	
	/** openId */
	@ApiModelProperty(value = "openId")
	private String openId;
	/**微信公众号*/
	@ApiModelProperty("微信公众号")
	private String wxOpenId;
	/**微信小程序*/
	@ApiModelProperty("微信小程序")
	private String minOpenId;
	/**
	 * 账户类型
	 */
	@ApiModelProperty(value = "账户类型 1-用户，2-商家")
	private int type;
	
	/**
	 * 账户是否绑定手机号 1-已绑定
	 */
	@ApiModelProperty(value = "账户是否绑定手机号：0-为绑定，1-已绑定")
	private int isBindPhone;
	
	/** 启用状态：0-禁用,1-启用 */
	@Column(name = "is_enable" )
	@ApiModelProperty(value = "启用状态：0-禁用,1-启用")
	private Integer isEnable;
	
	/** 性别：1女，2男 */
	@ApiModelProperty(value = "性别：1女，2男")
	private Integer gender;
	
	/** 用户邀请码 */
	@ApiModelProperty(value = "用户邀请码")
	private String userInvite;
	
	/** im账号 */
	@ApiModelProperty(value = "im账号")
	private String im;
	
	/** 等级 */
	@ApiModelProperty(value = "等级")
	private String level;
	
	/** 是否设置过密码（1-是、2-否） */
	@ApiModelProperty(value = "是否设置过密码（1-是、2-否）")
	private Integer isPassword = 1;
	

	public static String getCacheKey(String authentication) {
		return PREFIX_USER_SESSION + authentication;
	}
}
